<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">API流程统计表</ui:define>
    <ui:define name="content">


        <h:form>
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false" draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         actionListener="#{statApiFlowBean.onAutoSearch()}"
                                         rendered="#{statApiFlowBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         rendered="#{statApiFlowBean.isNormal()}"
                                         ajax="false">
                            <p:dataExporter type="xls" target="statisticRecordDataTable" fileName="api统计表"
                                            postProcessor="#{statApiFlowBean.postProcessXLS}"/>
                        </p:commandButton>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{statApiFlowBean.isNormal()}"
                                         actionListener="#{statApiFlowBean.onReset}"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="startTime" value="时间"/>
                                <p:calendar id="startTime" value="#{statApiFlowBean.$.startTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>
                                <p:outputLabel for="endTime" value=" - "/>
                                <p:calendar id="endTime" value="#{statApiFlowBean.$.endTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="selectBigProduct" value="大产品"/>
                                <p:selectCheckboxMenu id="selectBigProduct" value="#{statApiFlowBean.$.parentName}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{statApiFlowBean.dictionaries[DictionaryCode.API_FLOW_PROD]}"
                                                   var="dic"
                                                   itemLabel="#{dic.name}" itemValue="#{dic.name}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectApiId" value="API"/>
                                <p:selectCheckboxMenu id="selectApiId" value="#{statApiFlowBean.$.apiId}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{statApiFlowBean.apiList}"
                                                   var="loanApiInfos"
                                                   itemLabel="#{loanApiInfos.name}" itemValue="#{loanApiInfos.id}"/>
                                </p:selectCheckboxMenu>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <h1>分组条件</h1>
                            <p:selectManyButton value="#{statApiFlowBean.$.groupByConditions}">
                                <!-- <f:selectItem itemLabel="时间" itemValue="daytime"/>-->
                                <f:selectItem itemLabel="大产品" itemValue="product_name"/>
                                <f:selectItem itemLabel="API_ID" itemValue="api_id"/>
                            </p:selectManyButton>
                        </div>
                        <div class="card">
                            <p:dataTable id="statisticRecordDataTable"
                                         style="width: 100%;text-align:center"
                                         var="statApiFlow"
                                         value="#{statApiFlowBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{statApiFlowBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="时间">
                                    <h:outputText value="#{statApiFlow.date}"/>
                                </p:column>
                                <p:column headerText="产品" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.productName}"/>
                                </p:column>
                                <p:column headerText="用户标签" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.userTag}"/>
                                </p:column>
                                <p:column headerText="apiId" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.apiId}"/>
                                </p:column>
                                <p:column headerText="活跃" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.activeUv}"/>
                                </p:column>
                                <p:column headerText="详情旧uv" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.viewDetailOldUv}"/>
                                </p:column>
                                <p:column headerText="参与旧uv" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.clickDetailOldUv}"/>
                                </p:column>
                                <p:column headerText="详情新uv" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.viewDetailNewUv}"/>
                                </p:column>
                                <p:column headerText="参与新uv" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.clickDetailNewUv}"/>
                                </p:column>
                                <p:column headerText="访问api人数" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.viewApiUv}"/>
                                </p:column>
                                <p:column headerText="一推人数" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.viewApiUv}"/>
                                </p:column>
                                <p:column headerText="进件人数" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.viewApiUv}"/>
                                </p:column>
                                <p:column headerText="通过人数" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.viewApiUv}"/>
                                </p:column>
                                <p:column headerText="放款人数" style="text-align:center;">
                                    <h:outputText value="#{statApiFlow.loanUv}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>